﻿#pragma strict
/*
* @author Mikko Miettinen
*/
var hit : RaycastHit;

var myStyleLabel: GUIStyle;
var mesh1: GameObject;
var mesh2: GameObject;
var mesh3: GameObject;


function Start () {
// if this is first run of the game show tutorial/info plane
 if(PlayerPrefs.GetInt("firstRun") != 1){
 	//had to turn of txtMeshes renderers since they showed trough the plane
	mesh1.renderer.enabled =false;
	mesh2.renderer.enabled =false;
	mesh3.renderer.enabled =false;

	}else
	{
	//the game has been runned atleat once so we destroy the tutorial/info plane at start
	 Destroy (this.gameObject);
	}

}

function OnGUI(){
var resizeRatio = new Vector2(Screen.width / 480, Screen.height / 320);
GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(resizeRatio.x, resizeRatio.y, 1.0f));
 
//our instructions are printed here since this way we get multiline functionality
var InstructionString ="\n"
+"Painamalla FB-logoa ja kirjautumalla sisään,\n"
+"voit jakaa tuloksesi omalla sivullasi! \n\n"
+"Tämän jälkeen saat myös huipputuloksesi High \n"
+"Score sivustolle omalla nimelläsi ja voit yrittää\n"
+"päästä parhaiden joukkoon!";
GUI.Label(new Rect(Screen.width/100*5, Screen.height/100*15, 10, 10), InstructionString, myStyleLabel);
}

function Update () {
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
	if (Input.GetMouseButtonDown (0))
	{
		if (Physics.Raycast (ray,hit, 100)) 
		{ 
			if(this.gameObject){
			// player is done with tutorial/info plane and touches the screen to get rid of it
				mesh1.renderer.enabled =true;
				mesh2.renderer.enabled =true;
				mesh3.renderer.enabled =true;
				//variable to see if game has been run before
				PlayerPrefs.SetInt("firstRun",1);
				Destroy (this.gameObject);
				
			}
		}
	}
}


        